#Load relevant libraries
library(lpSolveAPI)

library(knitr)

library(kableExtra)

library(igraph)
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union

Question 1:

Code a “network map” showing the different routes workers and supplies may take to reach the African cities from the United States.

Network Map

Network Map

Question 2:

Given the distance (Table 3) and the speed of the transportation used (Table 1) between each pair of cities, how can Gail McGovern and the IFRC most quickly move workers from the United States to each of the nine IFRC cities?

Set Decision Variables: Decision Variables The amount of time it takes to get from NY or FL to each of the six IFRC cities with ports/airfields and then from the ports/airfields to each of the remaining three IRFC cities. Represented by Xzij where z = N, F, A, B, C, D, E, or K, i = P, S, or T, and j = A, B, C, D, E, K, G, H, or I.

Below are the codes used to represent each of these locations: New York, NY (N) Jacksonville, FL (F)

Airplane Speed is 400 MPH (P) Ship Speed is 35 MPH (S) Truck Speed is 50 MPH (T)

Dakar, Senegal (A) Khartoum, Sudan (D) Libreville, Gabon (B) Lusaka, Zambia (E) Lunda, Angola (C) Nairobi, Kenya (K) Niamey, Niger (G) Kosongo, D.R. Congo (H) Ndjamena, Chad (I)

Set Objective Function: Minimize time over getting required supplies to each of the 9 IFRC locations Minimize Time = 119.2NSA + 17.6025NPD + 172.1143NSB + 20.245NPE + 186.4571NSC + 20.125NPK + 112.1143FSA + 17.71FPD + 180.8286FSB + 19.86FPE + 195.0857FSC + 19.9025FPK + 33.12ATG + 92.46ATH + 54.5ATI + 5.1625DPG + 3.4425DPH + 3DPI + 20.64BTG + 36.84BTH + 28.3BTI + 10.175EPG + 1.865EPH + 5.275EPI + 58.32CTG + 27.78CTH + 53.04CTI + 6.31KPG + 2.725KPH + 4.42KPI

Set Constraints: Subject to
NSA + NPD + NSB + NPE + NSC + NPK >= 0 # New York travel routes FSA + FPD + FSB + FPE + FSC + FPK >= 0 # Florida travel routes -1NSA + -1FSA + ATG + ATH + ATI = 0 # Dakar, Senegal travel routes -1NPD + -1FPD + DPG + DPH + DPI = 0 # Khartoum, Sudan travel routes -1NSB + -1FSB + BTG + BTH + BTI = 0 # Libreville, Gabon travel routes -1NPE + -1FPE + EPG + EPH + EPI = 0 # Lusaka, Zambia travel routes -1NSC + -1FSC + CTG + CTH + CTI = 0 # Lunda, Angola travel routes -1NPK + -1FPK + KPG + KPH + KPI = 0 # Nairobi, Kenya travel routes -1ATG + -1DPG + -1BTG + -1EPG + -1CTG + -1KPG = -1 # Travel routes to Niamey, Niger -1ATH + -1DPH + -1BTH + -1EPH + -1CTH + -1KPH = -1 # Travel routes Kosongo, D.R. Congo -1ATI + -1DPI + -1BTI + -1EPI + -1CTI + -1KPI = -1 # Travel routes to Ndjamena, Chad

# set model with 30 decision variables
transport_time <- make.lp(0, 30)

# set objective function using travel time to next destination
Q2_obj_fn <- c(119.2, 17.6025, 172.1143, 20.245, 186.4571, 20.125, # NY
            112.1143, 17.71, 180.8286, 19.86, 195.0857, 19.9025, # FL
            33.12, 92.46, 54.5, # Dakar
            5.1625, 3.4425, 3, # Khartoum
            20.64, 36.84, 28.3, # Libreville
            10.175, 1.865, 5.275, # Lusaka
            58.32, 27.78, 53.04, # Luanda
            6.31, 2.725, 4.42) # Nairobi

# initiates the objective function to the model
set.objfn(transport_time, Q2_obj_fn)

# adds 11 constraints for in and out flow at locations
add.constraint(transport_time, c(1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ">=", 0)
add.constraint(transport_time, c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ">=", 0)
add.constraint(transport_time, c(-1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", -1)
add.constraint(transport_time, c(0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", -1)
add.constraint(transport_time, c(0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", -1)
add.constraint(transport_time, c(0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0), "=", -1)
add.constraint(transport_time, c(0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0), "=", -1)
add.constraint(transport_time, c(0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1), "=", -1)
add.constraint(transport_time, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0), "=", -1)
add.constraint(transport_time, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0), "=", -1)
add.constraint(transport_time, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1), "=", -1)

# adds dimnames
dimnames(transport_time) <- list(c("NY", "FL", "Dakar", "Khartoum", "Libreville", "Lusaka", "Luanda", "Nairobi", "Niamey", "Kosongo", "Ndjamena"),
                                 c("NY_Dakar", "NY_Khartoum", "NY_Libreville", "NY_Lusaka", "NY_Luanda", "NY_Nairobi",
                                 "FL_Dakar", "FL_Khartoum", "FL_Libreville", "FL_Lusaka", "FL_Luanda", "FL_Nairobi",
                                 "Dakar_Niamey", "Dakar_Kosongo", "Dakar_Ndjamena", 
                                 "Khartoum_Niamey", "Khartoum_Kosongo", "Khartoum_Ndjamena",
                                 "Libreville_Niamey", "Libreville_Kosongo", "Libreville_Ndjamena",
                                 "Lusaka_Niamey", "Lusaka_Kosongo", "Lusaka_Ndjamena",
                                 "Luanda_Niamey", "Luanda_Kosongo", "Luanda_Ndjamena",
                                 "Nairobi_Niamey", "Nairobi_Kosongo", "Nairobi_Ndjamena"))
# outputs algebraic formula
write.lp(transport_time, "Q2.lp", type = 'lp')

# solves the model
solve(transport_time)
## [1] 0
# gets the primal solution
primeQ2 <- get.primal.solution(transport_time)

# sensitivity analysis
obj_sa2 <- get.sensitivity.obj(transport_time)
rhs_sa2 <- get.sensitivity.rhs(transport_time)
n2 <- length(get.variables(transport_time))
m2 <- length(get.constr.type(transport_time))
ov2 <- paste0("Objective Value =", primeQ2[1])
sa_tab2 <- rbind(primeQ2[2:(n2 + m2 + 1)],
                c(round(rhs_sa2$duals[1:m2], 2), Q2_obj_fn),
                round(c(rhs_sa2$dualsfrom[1:m2],obj_sa2$objfrom), 2),
                round(c(rhs_sa2$dualstill[1:m2],obj_sa2$objtill), 2))
colnames(sa_tab2) <- c(rownames(transport_time), colnames(transport_time))
rownames(sa_tab2) <- c("solution", "duals/coef", "Sens From", "Sens Till")    
sa_tab2 <- ifelse(sa_tab2 == -1.000e+30, "-inf", sa_tab2)
sa_tab2 <- ifelse(sa_tab2 == 1.000e+30, "inf", sa_tab2)

# create table
kable(sa_tab2, format.args = list(big.mark = ",")) %>%
  kable_styling(bootstrap_options = c("striped", "bordered")) %>%
  add_footnote(label = ov2, notation = "none")
NY FL Dakar Khartoum Libreville Lusaka Luanda Nairobi Niamey Kosongo Ndjamena NY_Dakar NY_Khartoum NY_Libreville NY_Lusaka NY_Luanda NY_Nairobi FL_Dakar FL_Khartoum FL_Libreville FL_Lusaka FL_Luanda FL_Nairobi Dakar_Niamey Dakar_Kosongo Dakar_Ndjamena Khartoum_Niamey Khartoum_Kosongo Khartoum_Ndjamena Libreville_Niamey Libreville_Kosongo Libreville_Ndjamena Lusaka_Niamey Lusaka_Kosongo Lusaka_Ndjamena Luanda_Niamey Luanda_Kosongo Luanda_Ndjamena Nairobi_Niamey Nairobi_Kosongo Nairobi_Ndjamena
solution 6 3 -1 -0.999999999999999 -1 -0.999999999999999 -1 -1 -1 -1 -1 0 4 1 0 1 0 1 0 0 0.999999999999999 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
duals/coef 0 0 -112.11 -17.6 -172.11 -19.86 -186.46 -19.9 -22.76 -21.05 -20.6 119.2 17.6025 172.1143 20.245 186.4571 20.125 112.1143 17.71 180.8286 19.86 195.0857 19.9025 33.12 92.46 54.5 5.1625 3.4425 3 20.64 36.84 28.3 10.175 1.865 5.275 58.32 27.78 53.04 6.31 2.725 4.42
Sens From -inf -inf -inf -inf -inf -inf -inf -inf -inf -inf -inf 112.11 -inf 2.12 19.86 -6.74 19.9 -10.36 17.6 172.11 19.18 186.46 18.32 -89.35 -91.07 -91.51 -inf -inf -inf -149.35 -151.07 -151.51 2.9 1.19 0.74 -163.69 -165.41 -165.85 2.86 1.14 0.7
Sens Till inf inf 0 3 0 0 0 0 0 0 0 inf 17.71 180.83 inf 195.09 inf 119.2 inf inf 20.24 inf 20.12 inf inf inf 8.61 4.12 6.72 inf inf inf inf inf inf inf inf inf inf inf inf
Objective Value =592.4632
# Output: Objective function value
get.objective(transport_time)
## [1] 592.4632
# Output: Decision variables 
get.variables(transport_time)
##  [1] 0 4 1 0 1 0 1 0 0 1 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
# Output: Constraint variables
get.constraints(transport_time) 
##  [1]  6  3 -1 -1 -1 -1 -1 -1 -1 -1 -1

The following routes will most quickly move workers from the United States to each of the nine IFRC cities: New York, NY will send workers to Libreville, Lunda, and Khartoum. Jacksonville, FL will send workers to Dakar, Lusaka, and Nairobi. Khartoum, Sudan will send workers to Niamey, Kosongo, and Ndjamena.

How long will it take workers and supplies to reach each city using the quickest route?

Dakar, Senegal: (4 days 16 hours 6 minutes) 112.11 hours = FS1 -> 3924 miles / 35 mph # Fastest route FL to Dakar, Senegal

Khartoum, Sudan: (17 hours 36 minutes) 17.60 hours = NA4 -> 7041 miles / 400 mph # Fastest route NY to Khartoum, Sudan

Libreville, Gabon: (7 days 4 hours 6 minutes) 172.11 hours = NS2 -> 6024 miles / 35 mph # Fastest route NY to Libreville, Gabon

Lusaka, Zambia: (19 hours 58 minutes) 19.86 hours = FA5 -> 7944 miles / 400 mph # Fastest route FL to Lusaka, Zambia

Luanda, Angola: (7 days 18 hours 27 minutes) 186.46 hours = NS3 -> 6526 miles / 35 mph # Fastest route NY to Lunda, Angola

Nairobi, Kenya: (19 hours 54 minutes) 19.90 hours = FA6 -> 7961 miles / 400 mph # Fastest route FL to Nairobi, Kenya

Niamey, Niger: (22 hours 45 minutes) 22.76 hours = NA4 + 4A7 # Fastest route for total time to get supplies from NY to Khartoum, Sudan and then from Khartoum, Sudan to Niamey, Niger

Kosongo, D.R. Congo: (21 hours 2 minutes) 21.045 hours = NA4 + 4A8 # Fastest route for total time to get supplies from NY to Khartoum, Sudan and then from Khartoum, Sudan to Kosongo, D.R. Congo

Ndjamena, Chad: (20 hours 36 minutes) 20.6 hours = NA4 + 4A9 # Fastest route for total time to get supplies from NY to Khartoum, Sudan and then from Khartoum, Sudan to Ndjamena, Chad

Which routes appear to have significant time bottlenecks that the IFRC should work to reduce?

In general, it appears that all supplies leaving NY and FL by ship are the slowest to reach the IFRC destinations, which is unfortunate since the cargo ships are capable of transporting the most units of supplies when compared to the other modes of transportation (airplanes and trucks). Increasing the speed of the ships by 10 miles per hour can reduce the total travel time for supplies by a minimum of 24 hours (1 day) and 54 minutes and a maximum of 1 day 19 hours and 21 minutes. While this difference doesn't make a very significant difference in overall travel speed, it does have an incremental impact on decreasing the travel time of the cargo ships. See Table A below for further details.

Table A

Table A

Provide a table and/or network map indicating the quickest route and travel time between the United States and African cities on the network.

Fastest Route Network Map

Fastest Route Network Map

Question 3

How should the IFRC satisfy each African city’s need requirements at minimum cost?

Set Decision Variables: Decision Variables The amount it costs per unit sent from NY or FL to each of the six IFRC cities with ports/airfields and then from the ports/airfields to each of the remaining three IRFC cities. Represented by Xzij where z = N, F, A, B, C, D, E, or K, i = P, S, or T, and j = A, B, C, D, E, K, G, H, or I.

Below are the codes used to represent each of these locations: New York, NY (N) Jacksonville, FL (F)

Airplane (P) Ship (S) Truck (T)

Dakar, Senegal (A) Libreville, Gabon (B) Lunda, Angola (C) Khartoum, Sudan (D) Lusaka, Zambia (E) Nairobi, Kenya (K) Niamey, Niger (G) Kosongo, D.R. Congo (H) Ndjamena, Chad (I)

Set Objective Function: Minimize cost while getting required supplies to each of the 9 IFRC locations Minimize Cost = 32000NSA + 30000NSB + 30000NSC + 45000NPD + 50000NPE + 55000NPK + 56000FSA + 48000FSB + 44000FSC + 49000FPD + 57000FPE + 61000FPK + 5000ATG + 5000ATH + 9000ATI + 3000BTG + 4000BTH + 7000BTI + 3000CTG + 5000CTH + 8000CTI + 22000DPG + 19000DPH + 4000DPI + 24000EPG + 22000EPH + 23000EPI + 28000KPG + 25000KPH + 2000KPI

Set Constraints: Subject to
240NSA + 240NSB + 240NSC + 150NPD + 150NPE + 150NPK = 500000 # New York supply 240FSA + 240FSB + 240FSC + 150FPD + 150FPE + 150FPK = 500000 # Florida supply -2401NSA + -240FSA + 17.7ATG + 17.7ATH + 17.7ATI = -50000 # Dakar, Senegal demand -240NSB + -240FSB + 17.7BTG + 17.7BTH + 17.7BTI = -100000 # Libreville, Gabon demand -240NSC + -240FSC + 17.7CTG + 17.7CTH + 17.7CTI = -130000 # Lunda, Angola demand -150NPD + -150FPD + 150DPG + 150DPH + 150DPI = -90000 # Khartoum, Sudan demand -150NPE + -150FPE + 150EPG + 150EPH + 150EPI = -150000 # Lusaka, Zambia demand -150NPK + -150FPK + 150KPG + 150KPH + 150KPI = -120000 # Nairobi, Kenya demand
-17.7ATG + -17.7BTG + -17.7CTG + -150DPG + -150EPG + -150KPG = -100000 # Niamey, Niger demand -17.7ATH + -17.7BTH + -17.7CTH + -150DPH + -150EPH + -150KPH = -180000 # Kosongo, D.R. Congo demand -17.7ATI + -17.7BTI + -17.7CTI + -150DPI + -150EPI + -150KPI = -80000 # Ndjamena, Chad demand

-17.7ATI <= 14868 # Truck constraint -17.7BTI <= 14868 # Truck constraint -17.7CTI <= 14868 # Truck constraint

-150DPI <= 30000 # Airplane constraint -150EPI <= 30000 # Airplane constraint

# Create an lp with 30 decision variables
transport_cost <- make.lp(0, 30)

# set objective function using cost per unit to next destination
Q3_obj_fn <- c(32000, 30000, 30000, 45000, 50000, 55000,
               56000, 48000, 44000, 49000, 57000, 61000,
               5000, 5000, 9000,
               3000, 4000, 7000, 
               3000, 5000, 8000,
               22000, 19000, 4000,
               24000, 22000, 23000,
               28000, 25000, 2000)

# initiates the objective function to the model
set.objfn(transport_cost , Q3_obj_fn)
lp.control(transport_cost , sense = "min")
## $anti.degen
## [1] "fixedvars" "stalling" 
## 
## $basis.crash
## [1] "none"
## 
## $bb.depthlimit
## [1] -50
## 
## $bb.floorfirst
## [1] "automatic"
## 
## $bb.rule
## [1] "pseudononint" "greedy"       "dynamic"      "rcostfixing" 
## 
## $break.at.first
## [1] FALSE
## 
## $break.at.value
## [1] -1e+30
## 
## $epsilon
##       epsb       epsd      epsel     epsint epsperturb   epspivot 
##      1e-10      1e-09      1e-12      1e-07      1e-05      2e-07 
## 
## $improve
## [1] "dualfeas" "thetagap"
## 
## $infinite
## [1] 1e+30
## 
## $maxpivot
## [1] 250
## 
## $mip.gap
## absolute relative 
##    1e-11    1e-11 
## 
## $negrange
## [1] -1e+06
## 
## $obj.in.basis
## [1] TRUE
## 
## $pivoting
## [1] "devex"    "adaptive"
## 
## $presolve
## [1] "none"
## 
## $scalelimit
## [1] 5
## 
## $scaling
## [1] "geometric"   "equilibrate" "integers"   
## 
## $sense
## [1] "minimize"
## 
## $simplextype
## [1] "dual"   "primal"
## 
## $timeout
## [1] 0
## 
## $verbose
## [1] "neutral"
# add onstraints for in and out flow at locations
add.constraint(transport_cost , c(240, 240, 240, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", 500000) # NY
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 240, 240, 240, 150, 150, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", 500000) # FL
add.constraint(transport_cost , c(-240, 0, 0, 0, 0, 0, -240, 0, 0, 0, 0, 0, 0, 17.7, 17.7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", -50000) # Dakar, Senegal
add.constraint(transport_cost , c(0, -240, 0, 0, 0, 0, 0, -240, 0, 0, 0, 0, 0, 0, 0, 0, 17.7, 17.7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", -100000) # Libreville, Gabon
add.constraint(transport_cost , c(0, 0, -240, 0, 0, 0, 0, 0, -240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17.7, 17.7, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", -130000) # Lunda, Angola
add.constraint(transport_cost , c(0, 0, 0, -150, 0, 0, 0, 0, 0, -150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0, 0, 0, 0), "=", -90000) # Khartoum, Sudan
add.constraint(transport_cost , c(0, 0, 0, 0, -150, 0, 0, 0, 0, 0, -150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150, 0, 0, 0), "=", -150000) # Lusaka, Zambia
add.constraint(transport_cost , c(0, 0, 0, 0, 0, -150, 0, 0, 0, 0, 0, -150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 150, 150), "=", -120000) # Nairobi, Kenya
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -150, 0, 0, -150, 0, 0, -150, 0, 0), "=", -100000) # Niamey, Niger
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -17.7, 0, 0, -17.7, 0, 0, -17.7, 0, 0, -150, 0, 0, -150, 0, 0, -150, 0), "=", -180000) # Kosongo, D.R. Congo
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -17.7, 0, 0, -17.7, 0, 0, -17.7, 0, 0, -150, 0, 0, -150, 0, 0, -150), "=", -80000) # Ndjamena, Chad

# add truck constraints
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17.7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 14868) #Truck Constraint for Dakar_Ndjamena
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17.7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 14868) #Truck Constraint for Libreville_Ndjamena
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17.7, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 14868) #Truck Constraint for Lunda_Ndjamena

#add flight constraints
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0, 0, 0, 0), "<=", 30000) #Flight Constraint for Khartoum_Ndjamena
add.constraint(transport_cost , c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0, 0, 0), "<=", 30000) #Flight Constraint for Lusaka_Ndjamena




# adds dimnames
dimnames(transport_cost) <- list(c("NY", "FL", "Dakar", "Libreville", "Luanda", "Khartoum", "Lusaka", "Nairobi", "Niamey", "Kosongo", "Ndjamena", "Dakar_Ndjamena","Libreville_Ndjamena", "Lunda_Ndjamena",  "Khartoum_Ndjamena", "Lusaka_Ndjamena"),
                                 c("NY_Dakar", "NY_Libreville", "NY_Luanda", "NY_Khartoum", "NY_Lusaka", "NY_Nairobi",
                                   "FL_Dakar", "FL_Libreville", "FL_Luanda", "FL_Khartoum", "FL_Lusaka", "FL_Nairobi",
                                   "Dakar_Niamey", "Dakar_Kosongo", "Dakar_Ndjamena", 
                                   "Libreville_Niamey", "Libreville_Kosongo", "Libreville_Ndjamena",
                                   "Luanda_Niamey", "Luanda_Kosongo", "Luanda_Ndjamena",
                                   "Khartoum_Niamey", "Khartoum_Kosongo", "Khartoum_Ndjamena",
                                   "Lusaka_Niamey", "Lusaka_Kosongo", "Lusaka_Ndjamena",
                                   "Nairobi_Niamey", "Nairobi_Kosongo", "Nairobi_Ndjamena"))

# outputs algebraic formula
write.lp(transport_cost, "Q3.lp", type = 'lp')

# solves the model
solve(transport_cost)
## [1] 0
# gets the primal solution
primeQ3 <- get.primal.solution(transport_cost)

# sensitivity analysis
obj_sa3 <- get.sensitivity.obj(transport_cost)
rhs_sa3 <- get.sensitivity.rhs(transport_cost)
n3 <- length(get.variables(transport_cost))
m3 <- length(get.constr.type(transport_cost))
ov3 <- paste0("Objective Value =", primeQ3[1])
sa_tab3 <- rbind(primeQ3[2:(n3 + m3 + 1)],
                 c(round(rhs_sa3$duals[1:m3], 2), Q3_obj_fn),
                 round(c(rhs_sa3$dualsfrom[1:m3],obj_sa3$objfrom), 2),
                 round(c(rhs_sa3$dualstill[1:m3],obj_sa3$objtill), 2))
colnames(sa_tab3) <- c(rownames(transport_cost), colnames(transport_cost))
rownames(sa_tab3) <- c("solution", "duals/coef", "Sens From", "Sens Till")    
sa_tab3 <- ifelse(sa_tab3 == -1.000e+30, "-inf", sa_tab3)
sa_tab3 <- ifelse(sa_tab3 == 1.000e+30, "inf", sa_tab3)
# create table
kable(sa_tab3, format.args = list(big.mark = ",")) %>%
  kable_styling(bootstrap_options = c("striped", "bordered")) %>%
  add_footnote(label = ov3, notation = "none")
NY FL Dakar Libreville Luanda Khartoum Lusaka Nairobi Niamey Kosongo Ndjamena Dakar_Ndjamena Libreville_Ndjamena Lunda_Ndjamena Khartoum_Ndjamena Lusaka_Ndjamena NY_Dakar NY_Libreville NY_Luanda NY_Khartoum NY_Lusaka NY_Nairobi FL_Dakar FL_Libreville FL_Luanda FL_Khartoum FL_Lusaka FL_Nairobi Dakar_Niamey Dakar_Kosongo Dakar_Ndjamena Libreville_Niamey Libreville_Kosongo Libreville_Ndjamena Luanda_Niamey Luanda_Kosongo Luanda_Ndjamena Khartoum_Niamey Khartoum_Kosongo Khartoum_Ndjamena Lusaka_Niamey Lusaka_Kosongo Lusaka_Ndjamena Nairobi_Niamey Nairobi_Kosongo Nairobi_Ndjamena
solution 5e+05 5e+05 -49999.9999999999 -1e+05 -130000 -89999.9999999999 -150000 -120000 -1e+05 -180000 -80000.0000000002 0 0 0 30000 0 208.333333333333 1166.66666666667 541.666666666667 0 266.666666666667 0 0 0 0 1466.66666666667 733.333333333333 1133.33333333333 0 0 0 0 10169.4915254237 0 0 0 0 666.666666666667 0 200 0 0 0 0 0 333.333333333335
duals/coef 373.33 420 240 248.33 248.33 93.33 40 13.33 -53.33 22.34 0 0 0 0 -66.67 0 32000 30000 30000 45000 50000 55000 56000 48000 44000 49000 57000 61000 5000 5000 9000 3000 4000 7000 3000 5000 8000 22000 19000 4000 24000 22000 23000 28000 25000 2000
Sens From 5e+05 5e+05 -50000 -1e+05 -130000 -90000 -150000 -120000 -1e+05 -180000 -inf -inf -inf -inf 0 -inf 16440.68 -5315.25 16440.68 42000 48250 54000 43200 41200 41200 40648.31 56000 51000 5000 3852.5 4248 3000 -inf 4395.5 3000 4000 4395.5 -inf 10648.31 -inf 14000 2648.31 6000 10000 -1351.69 -8000
Sens Till 610000 inf 0 10000 -20000 130000 -40000 inf 0 -70000 inf inf inf inf 80000 inf 44800 36800 32800 inf 51000 inf inf inf inf 52000 58750 62000 inf inf inf inf 4985.5 inf inf inf inf 32000 inf 14000 inf inf inf inf inf 19000
Objective Value =310861299.435028
# Output: Objective function value
get.objective(transport_cost)
## [1] 310861299
# Output: Decision variables 
get.variables(transport_cost)
##  [1]   208.3333  1166.6667   541.6667     0.0000   266.6667     0.0000
##  [7]     0.0000     0.0000     0.0000  1466.6667   733.3333  1133.3333
## [13]     0.0000     0.0000     0.0000     0.0000 10169.4915     0.0000
## [19]     0.0000     0.0000     0.0000   666.6667     0.0000   200.0000
## [25]     0.0000     0.0000     0.0000     0.0000     0.0000   333.3333
# Output: Constraint variables
get.constraints(transport_cost) 
##  [1]  500000  500000  -50000 -100000 -130000  -90000 -150000 -120000 -100000
## [10] -180000  -80000       0       0       0   30000       0

The minimum cost to send the required supplies to each IFRC destination is $310861299 (when rounding up the number of airplanes/ships/trucks to account for decimal numbers the total cost is $311025000)

New York, NY sends 50,000 units on 209 ships to Dakar, Senegal, 280,000 units on 1167 ships to Libreville, Gabon, 130,000 units on 542 ships to Lunda, Angola and 40,000 units on 267 airplanes to Lusaka, Zambia.

Jacksonville, FL sends 220,000 units on 1467 airplanes to Khartoum, Sudan, 110,000 units on 734 airplanes to Lusaka, Zambia, and 170,000 units on 1134 airplanes to Nairobi, Kenya.

Libreville, Gabon sends 180,000 units on 10170 trucks to Kosongo, D.R. Congo.

Khartoum, Sudan sends 100,000 units on 667 airplanes to Niamey, Niger and 30,000 units on 200 airplanes to Ndjamena, Chad.

Nairobi, Kenya sends 50,000 units on 334 airplanes to Ndjamena, Chad.

Again, where are the significant bottlenecks in the system that the IFRC should work to reduce?

We have identified the following potential bottlenecks in this system. First, there is a 3 hour and 36 minute travel time difference between when the airplanes from Khartoum, Sudan will arrive in Ndjamena, Chad and when the airplanes from Nairobi, Kenya will arrive if they depart for Ndjamena at the same time. The next bottleneck we found was on the route to get supplies to Kosongo, D.R. Congo. Since the least expensive route is for supplies to come from NY to Libreville, Gabon and then from Libreville to Kosongo, D.R. Congo the total travel time for supplies coming from the US to arrive in Kosongo is 208 hours 57 minutes (8 days, 16 hours and 57 minutes). See Table B

Another bottleneck would be due to the cargo load size capabilities. With the current cargo restrictions, we are often sending one extra ship, airplane, or truck due to a small amount of remaining required supplies. If there was some way to increase the cargo load size to exactly match the required supplies, we could eliminate the extra transportation cost of one more trip that is carrying a load below capacity.

Table B

Table B

Provide a table and/or network map highlighting the least cost route between the U.S. and African cities.

Minimum Cost Network Map

Minimum Cost Network Map

Question 4:

How can the IFRC maximize the total amount of cargo that reaches Africa?

Set Decision Variables: Decision Variables The number of units sent per vessel type from NY or FL to each of the six IFRC cities with ports/airfields and then from the ports/airfields to each of the remaining three IRFC cities. Represented by Xzij where z = N, F, A, B, C, D, E, or K, i = P, S, or T, and j = A, B, C, D, E, K, G, H, or I.

Below are the codes used to represent each of these locations: New York, NY (N) Jacksonville, FL (F)

Airplane (P) Ship (S) Truck (T)

Dakar, Senegal (A) Khartoum, Sudan (D) Libreville, Gabon (B) Lusaka, Zambia (E) Lunda, Angola (C) Nairobi, Kenya (K) Niamey, Niger (G) Kosongo, D.R. Congo (H) Ndjamena, Chad (I)

Set Objective Function: Maximize units sent from the US to each of the IFRC locations Maximize Units = 240NSA + 150NPD + 240NSB + 150NPE + 240NSC + 150NPK + 240FSA + 150FPD + 240FSB + 150FPE + 240FSC + 150FPK + 17.7ATG + 17.7ATH + 17.7ATI + 150DPG + 150DPH + 150DPI + 17.7BTG + 17.7BTH + 17.7BTI + 150EPG + 150EPH + 150EPI + 17.7CTG + 17.7CTH + 17.7CTI + 150KPG + 150KPH + 150KPI

Set Constraints: Subject to
NSA + NPD + NSB + NPE + NSC + NPK <= 500000 # New York supply FSA + FPD + FSB + FPE + FSC + FPK <= 500000 # Florida supply -1NSA + -1FSA + ATG + ATH + ATI >= -50000 # Dakar, Senegal demand -1NSB + -1FSB + BTG + BTH + BTI >= -100000 # Libreville, Gabon demand -1NSC + -1FSC + CTG + CTH + CTI >= -130000 # Lunda, Angola demand -1NPD + -1FPD + DPG + DPH + DPI >= -90000 # Khartoum, Sudan demand -1NPE + -1FPE + EPG + EPH + EPI >= -150000 # Lusaka, Zambia demand -1NPK + -1FPK + KPG + KPH + KPI >= -120000 # Nairobi, Kenya demand
-1ATG + -1BTG + -1CTG + -1DPG + -1EPG + -1KPG >= -100000 # Niamey, Niger demand -1ATH + -1BTH + -1CTH + -1DPH + -1EPH + -1KPH >= -180000 # Kosongo, D.R. Congo demand -1ATI + -1BTI + -1CTI + -1DPI + -1EPI + -1KPI >= -80000 # Ndjamena, Chad demand

NPE <= 45000 # Airplane constraint NPK <= 75000 # Airplane constraint NPD <= 75000 # Airplane constraint FPE <= 75000 # Airplane constraint FPK <= 105000 # Airplane constraint FPD <= 90000 # Airplane constraint EPG <= 30000 # Airplane constraint KPG = 0 # Airplane constraint DPG <= 45000 # Airplane constraint EPH <= 21000 # Airplane constraint KPH <= 6000 # Airplane constraint DPH <= 12000 # Airplane constraint EPI = 0 # Airplane constraint KPI <= 45000 # Airplane constraint DPI <= 6000 # Airplane constraint

CTH <= 4425 # Truck constraint CTI <= 4248 # Truck constraint BTH <= 5310 # Truck constraint BTI <= 2832 # Truck constraint ATH <= 12390 # Truck constraint ATI <= 7965 # Truck constraint

#options(scipen = 999)

# set model with 30 decision variables
transport_cargo <- make.lp(0, 30)

# set objective function using cargo units per travel type to next destination
Q4_obj_fn <- c(240, 150, 240, 150, 240, 150, # NY
               240, 150, 240, 150, 240, 150, # FL
               17.7, 17.7, 17.7, # Dakar
               150, 150, 150, # Khartoum
               17.7, 17.7, 17.7, # Libreville
               150, 150, 150, # Lusaka
               17.7, 17.7, 17.7, # Luanda
               150, 150, 150)# Nairobi

# initiate the objective function to the model
set.objfn(transport_cargo, Q4_obj_fn) 

lp.control(transport_cargo, sense = "max")
## $anti.degen
## [1] "fixedvars" "stalling" 
## 
## $basis.crash
## [1] "none"
## 
## $bb.depthlimit
## [1] -50
## 
## $bb.floorfirst
## [1] "automatic"
## 
## $bb.rule
## [1] "pseudononint" "greedy"       "dynamic"      "rcostfixing" 
## 
## $break.at.first
## [1] FALSE
## 
## $break.at.value
## [1] 1e+30
## 
## $epsilon
##       epsb       epsd      epsel     epsint epsperturb   epspivot 
##      1e-10      1e-09      1e-12      1e-07      1e-05      2e-07 
## 
## $improve
## [1] "dualfeas" "thetagap"
## 
## $infinite
## [1] 1e+30
## 
## $maxpivot
## [1] 250
## 
## $mip.gap
## absolute relative 
##    1e-11    1e-11 
## 
## $negrange
## [1] -1e+06
## 
## $obj.in.basis
## [1] TRUE
## 
## $pivoting
## [1] "devex"    "adaptive"
## 
## $presolve
## [1] "none"
## 
## $scalelimit
## [1] 5
## 
## $scaling
## [1] "geometric"   "equilibrate" "integers"   
## 
## $sense
## [1] "maximize"
## 
## $simplextype
## [1] "dual"   "primal"
## 
## $timeout
## [1] 0
## 
## $verbose
## [1] "neutral"
# add constraints for in and out flow at locations
add.constraint(transport_cargo, c(1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 500000) #NY
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 500000) #FL
add.constraint(transport_cargo, c(-1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ">=", -50000) #Dakar
add.constraint(transport_cargo, c(0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ">=", -90000) #Khartoum
add.constraint(transport_cargo, c(0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), ">=", -100000) #Libreville
add.constraint(transport_cargo, c(0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0), ">=", -150000) #Lusaka
add.constraint(transport_cargo, c(0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0), ">=", -130000) #Lunda
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1), ">=", -120000) #Nairobi
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0), ">=", -100000) #Niamey
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0), ">=", -180000) #Kosongo
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1), ">=", -80000) #Ndjamena

# add air constraints
add.constraint(transport_cargo, c(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 45000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 75000)
add.constraint(transport_cargo, c(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 75000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 75000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 105000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 90000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 30000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0), "=", 0)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 45000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0), "<=", 21000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0), "<=", 6000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 12000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), "=", 0)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1), "<=", 45000)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 6000)

# add truck constraints
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0), "<=", 4425)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0), "<=", 4248)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 5310)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 2832)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 12390)
add.constraint(transport_cargo, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "<=", 7965)

# add dimnames
dimnames(transport_cargo) <- list(c("NY", "FL", "Dakar", "Khartoum", "Libreville", "Lusaka", "Luanda", "Nairobi", "Niamey", "Kosongo", "Ndjamena", "NY_Lusaka", "NY_Nairobi", "Ny_Khartoum", "FL_Lusaka", "FL_Nairobi", "FL_Khartoum", "Lusaka_Niamey", "Nairobi_Niamey", "Khartoum_Niamey", "Lusaka_Kosongo", "Nairobi_Kosongo", "Khartoum_Kosongo", "Lusaka_Ndjamena", "Nairobi_Ndjamena", "Khartoum_Ndjamena", "Luanda_Kosongo", "Luanda_Ndjamena", "Libreville_Kosongo", "Libreville_Ndjamena", "Dakar_Kosongo", "Dakar_Ndjamena"),
                                  c("NY_Dakar", "NY_Khartoum", "NY_Libreville", "NY_Lusaka", "NY_Luanda", "NY_Nairobi", "FL_Dakar", "FL_Khartoum", "FL_Libreville", "FL_Lusaka", "FL_Luanda", "FL_Nairobi", "Dakar_Niamey", "Dakar_Kosongo", "Dakar_Ndjamena", "Khartoum_Niamey", "Khartoum_Kosongo", "Khartoum_Ndjamena", "Libreville_Niamey", "Libreville_Kosongo", "Libreville_Ndjamena", "Lusaka_Niamey", "Lusaka_Kosongo", "Lusaka_Ndjamena", "Luanda_Niamey", "Luanda_Kosongo", "Luanda_Ndjamena", "Nairobi_Niamey", "Nairobi_Kosongo", "Nairobi_Ndjamena"))

# outputs algebraic formula
write.lp(transport_cargo, "Q4.lp", type = 'lp')

# solves the model
solve(transport_cargo)
## [1] 0
# gets the primal solution
primeQ4 <- get.primal.solution(transport_cargo)

# sensitivity analysis
obj_sa4 <- get.sensitivity.obj(transport_cargo)
rhs_sa4 <- get.sensitivity.rhs(transport_cargo)
n4 <- length(get.variables(transport_cargo))
m4 <- length(get.constr.type(transport_cargo))
ov4 <- paste0("Objective Value =", primeQ4[1])
sa_tab4 <- rbind(primeQ4[2:(n4 + m4 + 1)],
                 c(round(rhs_sa4$duals[1:m4], 2), Q4_obj_fn),
                 round(c(rhs_sa4$dualsfrom[1:m4],obj_sa4$objfrom), 2),
                 round(c(rhs_sa4$dualstill[1:m4],obj_sa4$objtill), 2))
colnames(sa_tab4) <- c(rownames(transport_cargo), colnames(transport_cargo))
rownames(sa_tab4) <- c("solution", "duals/coef", "Sens From", "Sens Till")    
sa_tab4 <- ifelse(sa_tab4 == -1.000e+30, "-inf", sa_tab4)
sa_tab4 <- ifelse(sa_tab4 == 1.000e+30, "inf", sa_tab4)
# create table
kable(sa_tab4, format.args = list(big.mark = ",")) %>%
  kable_styling(bootstrap_options = c("striped", "bordered")) %>%
  add_footnote(label = ov4, notation = "none")
NY FL Dakar Khartoum Libreville Lusaka Luanda Nairobi Niamey Kosongo Ndjamena NY_Lusaka NY_Nairobi Ny_Khartoum FL_Lusaka FL_Nairobi FL_Khartoum Lusaka_Niamey Nairobi_Niamey Khartoum_Niamey Lusaka_Kosongo Nairobi_Kosongo Khartoum_Kosongo Lusaka_Ndjamena Nairobi_Ndjamena Khartoum_Ndjamena Luanda_Kosongo Luanda_Ndjamena Libreville_Kosongo Libreville_Ndjamena Dakar_Kosongo Dakar_Ndjamena NY_Dakar NY_Khartoum NY_Libreville NY_Lusaka NY_Luanda NY_Nairobi FL_Dakar FL_Khartoum FL_Libreville FL_Lusaka FL_Luanda FL_Nairobi Dakar_Niamey Dakar_Kosongo Dakar_Ndjamena Khartoum_Niamey Khartoum_Kosongo Khartoum_Ndjamena Libreville_Niamey Libreville_Kosongo Libreville_Ndjamena Lusaka_Niamey Lusaka_Kosongo Lusaka_Ndjamena Luanda_Niamey Luanda_Kosongo Luanda_Ndjamena Nairobi_Niamey Nairobi_Kosongo Nairobi_Ndjamena
solution 5e+05 316170 -50000 -90000 -1e+05 -99000 -130000 -120000 -1e+05 -61125 -66045 45000 66000 75000 75000 105000 78000 0 0 45000 21000 6000 12000 0 45000 6000 4425 4248 5310 2832 12390 7965 67185 75000 108142 45000 138673 66000 58170 78000 0 75000 0 105000 55000 12390 7965 45000 12000 6000 0 5310 2832 0 21000 0 0 4425 4248 0 6000 45000
duals/coef 0 0 -240 -150 -240 0 -240 -150 -257.7 0 0 150 0 0 150 0 0 0 42.3 42.3 150 300 300 150 300 300 257.7 257.7 257.7 257.7 257.7 257.7 240 150 240 150 240 150 240 150 240 150 240 150 17.7 17.7 17.7 150 150 150 17.7 17.7 17.7 150 150 150 17.7 17.7 17.7 150 150 150
Sens From 432815 -inf -233830 -102000 -167185 -inf -197185 -129000 -283830 -inf -inf 0 -inf 63000 0 96000 -inf -inf 0 0 0 0 0 0 0 0 0 0 0 0 0 0 240 150 240 0 240 0 240 107.7 -inf 0 -inf 150 17.7 -240 -240 107.7 -150 -150 -inf -240 -240 -inf 0 -inf -inf -240 -240 -inf -150 -150
Sens Till 558170 inf 8170 -12000 -41830 inf -71830 -61830 -45000 inf inf 96000 inf 142185 126000 163170 inf inf 9000 57000 139875 15000 24000 13955 54000 18000 71610 18203 72495 16787 131265 21920 240 inf 240 inf 240 150 240 150 240 inf 240 inf 60 inf inf inf inf inf 17.7 inf inf 257.7 inf inf 17.7 inf inf inf inf inf
Objective Value =177802209
# Output: Objective function value
get.objective(transport_cargo)
## [1] 177802209
# Output: Decision variables 
get.variables(transport_cargo)
##  [1]  67185  75000 108142  45000 138673  66000  58170  78000      0  75000
## [11]      0 105000  55000  12390   7965  45000  12000   6000      0   5310
## [21]   2832      0  21000      0      0   4425   4248      0   6000  45000
# Output: Constraint variables
get.constraints(transport_cargo) 
##  [1]  500000  316170  -50000  -90000 -100000  -99000 -130000 -120000 -100000
## [10]  -61125  -66045   45000   66000   75000   75000  105000   78000       0
## [19]       0   45000   21000    6000   12000       0   45000    6000    4425
## [28]    4248    5310    2832   12390    7965

Maximum units sent to Africa: 816,170 Units

New York will send 500,000 total units to Africa. 67185 units to Dakar, Senegal, 75000 units to Khartoum, Sudan, 108142 units to Libreville, Gabon, 45000 units to Luska, Zambia, 138673 units to Lunda, Angola, and 66000 units to Nairobi, Kenya.

Florida will send 316170 total units to Africa. 58170 units to Dakar, Senegal, 78000 units to Khartoum, Sudan, 75000 units to Luska, Zambia, and 105000 units to Nairobi, Kenya.

Dakar, Senegal will send 55000 units to Niamey, Niger, 12390 units to Kosongo, D.R. Congo, and 7965 units to Ndjamena, Chad. Dakar will keep 50,000 units.

Khartoum, Sudan will send 45000 units to Niamey, Niger, 12000 units to Kosongo, D.R. Congo, and 6000 units to Ndjamena, Chad. Khartoum will keep 90,000 units.

Libreville, Gabon will send 5310 units to Kosongo, D.R. Congo, and 2832 units to Ndjamena, Chad. Libreville will keep 100,000 units.

Lusaka, Zambia will send 21000 units to Kosongo, D.R. Congo. Lusaka will keep 99,000 units.

Lunda, Angola will send 4425 units to Kosongo, D.R. Congo, and 4248 units to Ndjamena, Chad. Lunda will keep 130,000 units.

Nairobi, Kenya will send 6000 units to Kosongo, D.R. Congo, and 45000 units to Ndjamena, Chad. Nairobi will keep 120,000 units.

Niamey will receive 100,000 units. Kosongo will receive 61,125 units. Ndjamena will receive 66,045 units.

Again, where are the significant bottlenecks in the system that the IFRC should work to reduce?

The most significant bottlenecks in this system are the airplane and truck restrictions for delivering supplies to Lusaka, Zambia, Kosongo, D.R. Congo and Ndjamena, Chad. The result of these restrictions is the US under-delivering on units of required supplies. Kosongo, D.R. Congo has the largest difference in delivered supplies to required supplies by -118,875 units, followed by Lusaka with -51,000 units, and Chad is not receiving -13,955 units compared to their requirements. See Table C below.

Table C

Table C

Provide a table and/or network map highlighting the maximum cargo and routes between the U.S. and African cities.

Maximum Cargo Network Map

Maximum Cargo Network Map